import flash.events.Event;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Matrix;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.text.TextFormat;

import CustomSprite;

import Images;
import Button;
class PopUpTextEvent extends Event{
public var Number:String;
	public function new(customEventString:String,inNumber:String){
        Number = inNumber;
	super(customEventString, true, false);

    }
}

class PopUpText extends CustomSprite
{
private var OKButton:Sprite;
public var text:TextField;
public var input:TextField;
  public function new(inBackground:BitmapData,Message:String)
  {
  super();
  var Background = new CustomSprite();
  Background.graphics.beginBitmapFill(inBackground);
  Background.graphics.drawRect(0, 0, inBackground.width, inBackground.height);
  Background.alpha = 0.5;
  addChild(Background);
 
  var TextBackground = new CustomSprite();
  TextBackground.graphics.beginBitmapFill(inBackground.clone());
  TextBackground.graphics.drawRect(0, 0, inBackground.width, inBackground.height);
  TextBackground.resize(350,200);
  TextBackground.x = 150;TextBackground.y = 150;
  addChild(TextBackground);
   
  text = new TextField();
  text.htmlText = Message;
  addChild(text);
  text.x = 200; text.y= 200;
  text.width = 350; text.height=50;

  input = new TextField();
  input.type = TextFieldType.INPUT;
  addChild(input);
  input.x = 175; input.y= 225;
  input.width = 200; input.height=50;
  input.border = true;
  input.maxChars = 22;

  OKButton = new Button(125,48,"OK");
  OKButton.x = 259;
  OKButton.y = 300;
  OKButton.buttonMode = true;
  OKButton.addEventListener(MouseEvent.CLICK, onOKButtonClick);
  addChild(OKButton);

  }
public function Load()
{
  //flash.Lib.current.addChild(this);
}
private function onOKButtonClick(event:MouseEvent) {
    Back();
}
  public function Back()
  {
  dispatchEvent(new PopUpTextEvent("PopUpTextEvent",input.text));
  //flash.Lib.current.removeChild(this);
  }



}